<?php
$GLOBALS['ENV']=Array();
$GLOBALS['debug']=1;
ini_set('session.use_cookies', 1);
ini_set('session.name', 'CAKEPHP');
session_start();
require_once('config/config.php');
require_once('lib/lib.php');
require_once('lib/app.php');
require_once('lib/dispatcher.php');
require_once('lib/configure.php');
require_once('lib/controller.php');
require_once('lib/model.php');
require_once('lib/view.php');
require_once('app/app_model.php');
require_once('app/app_controller.php');
try{
	require_once('lib/components/Component.php');
	require_once('lib/components/RequestHandler.php');
	$GLOBALS["ENV"]["db"]["connection"]=mysql_connect($GLOBALS["CONFIG"]["db"]["host"],$GLOBALS["CONFIG"]["db"]["username"],$GLOBALS["CONFIG"]["db"]["password"]);
	if(!mysql_select_db($GLOBALS["CONFIG"]["db"]["table"],$GLOBALS["ENV"]["db"]["connection"])){
		die('Cannot connect Database. check Confg.php');
	}
	mysql_set_charset('utf8',$GLOBALS["ENV"]["db"]["connection"]);
	dispatch();
	mysql_close($GLOBALS["ENV"]["db"]["connection"]);
}catch(Exception $e){
	print_r($e);
	die($e->getMessage());
	mysql_close($GLOBALS["ENV"]["db"]["connection"]);
}